﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;
using System.Xml;

namespace FreightForwarderTest
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                //Log.Logger.Writer("Work1", Log.QueueStatus.Open, "111");
                //Log.Logger.Writer("Work1", Log.QueueStatus.Close, "112");
                Thread mythread;
                //doWork1();
                for (int i = 1; i <= 100; i++)
                {
                    mythread = new Thread(Form1.doWork1);
                    mythread.Start(i);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        public static void doWork1(object threadName)
        {
            Int64 i = 1;
            while (i < 100)
            {
                Log.Logger.Writer("Work" + threadName.ToString(), Log.QueueStatus.Open, "Work" + threadName.ToString() + i.ToString());

                i++;
            }
            Log.Logger.Writer("Work" + threadName.ToString(), Log.QueueStatus.Close, "Work" + threadName.ToString() + "1000000");
        }



        private void button2_Click(object sender, EventArgs e)
        {
            string Xml = @"<?xml version='1.0' encoding='GB2312'?><root>  <Item>     <INCOME_INVOICE_NUM>101</INCOME_INVOICE_NUM>     <ORDER_STATU>1</ORDER_STATU>   </Item>   <Item>     <INCOME_INVOICE_NUM>102</INCOME_INVOICE_NUM>     <ORDER_STATU>1</ORDER_STATU>   </Item> </root>
";
            System.Xml.XmlDocument xml = new System.Xml.XmlDocument();
            xml.LoadXml(Xml);
            foreach (XmlNode item in xml.SelectNodes("//Item"))
            {
                Console.Write(item.SelectSingleNode(".//INCOME_INVOICE_NUM").Value);
            }
            
            //TaxService.TaxService tax = new TaxService.TaxService();
            //string message = tax.DeleteInvoiceInfo(Xml);
            //MessageBox.Show(message);
        }

        private void button3_Click(object sender, EventArgs e)
        {

        }

        private void button4_Click(object sender, EventArgs e)
        {
            Form2 crform = new Form2();
            crform.Show();
        }

        private void button5_Click(object sender, EventArgs e)
        {
            //TaxService.TaxService tax = new TaxService.TaxService();
            //string xml = @" <?xml version=""1.0"" encoding=""UTF-8"" ?> - <root><TAX_INVOICE_NUM />   <INCOME_INVOICE_DATE_START>2014-09-01</INCOME_INVOICE_DATE_START>   <INCOME_INVOICE_DATE_END>2014-10-16</INCOME_INVOICE_DATE_END> <INVOICE_TITLE />   <STATION_NUM />   <MACHINE_NUM>0</MACHINE_NUM>   <ORDER_NUM>9</ORDER_NUM>   </root>";

            //string ABC = tax.GetInvoiceInfo(xml);
            //string abd = "";

            this.ReturnInvoice();

        }
        private void ReturnInvoice()
        {
            TaxService.TaxService tax = new TaxService.TaxService();
            string xml = @"<?xml version=""1.0"" encoding=""utf-8""?><root>   <T_FPHDR_OUT>        
<INCOME_INVOICE_NUM>2814</INCOME_INVOICE_NUM>    
<TAX_INVOICE_NUM>02638648</TAX_INVOICE_NUM>        <TOTAL_MONEY>100</TOTAL_MONEY>   
<INVOICE_STATU>1</INVOICE_STATU>        <T_FPITEM_OUT>            <INCOME_INVOICE_LINE_ID>1</INCOME_INVOICE_LINE_ID>     
<INCOME_INVOICE_NUM>3853</INCOME_INVOICE_NUM>            <TAXES>5.66</TAXES>       
<NO_TAX_AMOUNT>94.34</NO_TAX_AMOUNT> 
<TOTAL_TAX_PRICE>100</TOTAL_TAX_PRICE></T_FPITEM_OUT>
</T_FPHDR_OUT> </root>";
            string rtn=tax.ReturnInvoiceInfo(xml);
            string qw = "";

        }

    }
}
